import axios from 'axios';

export default {
    install: function(Vue, options) {

        let service = {

            // 根据配置CODE获取配置项
            getConfigByCode(code) {
                return axios.get(`/config/code/${code}`);
            },

            // 根据配置范围获取配置列表
            getConfigsByScope(scope) {
                return axios.get(`/config/scope/${scope}/value`);
            },

            // 获取所有配置项
            getAllConfigs() {
                return axios.get('/config');
            },

            // 更新配置项
            modifyConfig(code, value) {
                return axios.put('/config', {
                    ConfigCode: code,
                    ConfigValue: value
                });
            }
        }

        Vue.prototype.$ConfigService = service;
    }
}